<template>
    <v-chart
        :options="polar"
    />
</template>

<script>
    export default {
        props: {
            // 数据
            dataInfo: {
                type: Array,
                default: () => []
            },
            // 图形 name
            name: {
                type: String,
                default: ''
            },
            titleText: {
                type: String,
                default: ''
            },
            legendData: {
                type: Array,
                default: () => []
            }
        },
        data () {
            return {

            };
        },
        computed: {
            polar () {
                return {
                    title: {
                        text: this.titleText,
                        // subtext: '动态数据',
                        x: 'center'
                    },
                    legend: {
                        show: true,
                        orient: 'vertical',
                        left: 'left',
                        data: this.legendData
                    },
                    tooltip: {
                        trigger: 'item',
                        formatter: '{a} <br/>{b} : {c} ({d}%)'
                    },
                    series: [
                        {
                            name: this.name,
                            type: 'pie',
                            radius: '55%',
                            center: ['50%', '60%'],
                            data: this.dataInfo,
                            itemStyle: {
                                emphasis: {
                                    shadowBlur: 10,
                                    shadowOffsetX: 0,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            }
                        }
                    ]
                };
            }
        }
    };
</script>

<style scoped>

</style>
